/*
 * Copyright 2002-2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.spice.servlet.dispatcher.handler;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**

 * @author Karthik Rajkumar
 * @version included from the RED-CHILLIES version
 */
public class SpiceSingleton {

    private SpiceSingleton(){

        // Creating private instance.
    }

    private static SpiceSingleton instance;


    public static SpiceSingleton getInstance() {

        if(instance == null)
            instance = new SpiceSingleton();

        return instance;
    }



    private List<Class<?>> listOfClasses = new ArrayList<Class<?>>();


    private List<Class<?>> listOfInterceptor = new ArrayList<Class<?>>();


    private Map<String, Object> classInstance = new HashMap<String, Object>();


    public void setListOfClasses(final List<Class<?>> listOfClasses){
        this.listOfClasses = listOfClasses;

    }

    public List<Class<?>> getListOfClasses(){
        return listOfClasses;
    }

    public Object getClassInstance(final String className) {
        return classInstance.get(className);
    }

    public void setClassInstance(String className, Object classInstance) {
        this.classInstance.put(className, classInstance);
    }


    public List<Class<?>> getIntercept(){
        return listOfInterceptor;
    }

    public void setIntercept(final List<Class<?>> intercept){
        this.listOfInterceptor = intercept;
    }
    
    public void setSingleIntercept(final Class<?> intercept){
    	this.listOfInterceptor.add(intercept);
    }
}
